package com.feizhou.swagger.config.routes;

import com.feizhou.swagger.controller.SwaggerController;
import com.feizhou.swagger.utils.ClassHelper;
import com.jfinal.config.Routes;

/**
 * 默认路由
 *
 * @author lee
 * @version V1.0.0
 * @date 2017/7/8
 */
public class SwaggerRoutes extends Routes {

    //获取所有的路由信息
    private Routes routes;

    public SwaggerRoutes(Routes routes) {
        System.out.println("拿到了全部路由信息 "+routes.getRouteItemList().size());
        //TODO 提取路由信息到ClassHelper内部一个map中，这样可以根据Class获取对于的url映射前缀
        for(Routes.Route route : routes.getRouteItemList()){
            System.out.print(route.getControllerKey() + " : ");
            System.out.println(route.getControllerClass());
            ClassHelper.addRoute(route.getControllerClass(),route.getControllerKey());
        }
    }

    @Override
    public void config() {
        setBaseViewPath("/WEB-INF/views");
        add("/swagger", SwaggerController.class);
    }

}
